package priv.pront.code.lanqiao.competition.course.date0403;

import java.util.Arrays;
import java.util.Scanner;

public class 砍树 {
    static long left, right;
    static long[] arr;
    static long m;
    static int n;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);
        left = 0;
        while (left <= right) {
            long mid = left + (right - left) / 2;
            if(check(mid)){
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        System.out.println(right);
    }

    private static boolean check(long k) {
        long sum = 0;
        for (long i : arr) {
            sum += Math.max(0, i - k);
        }
        return sum < m;
    }
}
